

//
//  UIBarButtonItem+Extensions.swift
//  仿微博
//
//  Created by 杨大伟 on 2016/12/13.
//  Copyright © 2016年 apple. All rights reserved.
//

import UIKit



extension UIBarButtonItem {
//便利构造函数
    
   //  title  title
    
   // fontSize  默认16号
    
   //  target
   
   //   action
   //   isBack  是否是加上返回箭头

    convenience init(title: String, fontSize: CGFloat = 16, target: AnyObject?, action: Selector, isBack: Bool = false) {
        let btn: UIButton = UIButton.cz_textButton(title, fontSize: fontSize, normalColor: UIColor.darkGray, highlightedColor: UIColor.orange)
        if isBack {
         let imageName = "navigationbar_back_withtext"
            btn.setImage(UIImage(named: imageName), for: UIControlState(rawValue: 0))
            btn.setImage(UIImage(named: imageName + "_highlighted"), for: .highlighted)
            btn.sizeToFit()
        
        
        }
        btn.addTarget(target, action:action, for: .touchUpInside)
        
       // self.init 实例化 UIBarButtonItem
        self.init(customView: btn)
    }



   

}
